home *** CD-ROM | disk | FTP | other *** search
/ GameStar 1998 November (Bonus) / GAMESTAR11B.ISO / ENCYC99 / MM / T620277A.DCR / Scripts_1_Class CursorGod.ls < prev    next >
Encoding:
Text File  |  1998-06-29  |  4.3 KB  |  190 lines

  1. property objectList, activeObject, thisStillDown, thisRollOver, thisMouseLoc, newstilldown, newrollover, newmouseloc, sendmouseclick, thestagerect, onstage
  2.  
  3. on new me
  4.   global savedcursor
  5.   set activeObject to 0
  6.   set objectList to []
  7.   set thisRollOver to 0
  8.   set thisStillDown to 0
  9.   set thisMouseLoc to point(-1, -1)
  10.   set newstilldown to 0
  11.   set newrollover to 0
  12.   set newmouseloc to 0
  13.   if voidp(savedcursor) then
  14.     set savedcursor to #plain
  15.   end if
  16.   set thestagerect to rect(0, 0, the stageRight - the stageLeft, the stageBottom - the stageTop)
  17.   set onstage to 0
  18.   return me
  19. end
  20.  
  21. on subscribe me, whichObject
  22.   if getPos(objectList, whichObject) = 0 then
  23.     add(objectList, whichObject)
  24.   end if
  25. end
  26.  
  27. on unsubscribe me, whichObject
  28.   deleteOne(objectList, whichObject)
  29. end
  30.  
  31. on mouseCheck me
  32.   if sendmouseclick then
  33.     set sendmouseclick to 0
  34.     sendoff("mouse click")
  35.   end if
  36.   set theMouseLoc to point(the mouseH, the mouseV)
  37.   set nowonstage to inside(theMouseLoc, thestagerect)
  38.   if nowonstage <> onstage then
  39.     set onstage to nowonstage
  40.     if onstage then
  41.       resetcursor(me)
  42.     end if
  43.   end if
  44.   if onstage then
  45.     areYouThere(me, theMouseLoc)
  46.   end if
  47. end
  48.  
  49. on areYouThere me, xLoc
  50.   set nextstilldown to the stillDown
  51.   set newstilldown to nextstilldown <> thisStillDown
  52.   if newstilldown then
  53.     if nextstilldown then
  54.       set sendmouseclick to 1
  55.     end if
  56.   end if
  57.   set thisStillDown to nextstilldown
  58.   set newmouseloc to xLoc <> thisMouseLoc
  59.   set thisMouseLoc to xLoc
  60.   if activeObject = 0 then
  61.     if not thisStillDown then
  62.       repeat with i in objectList
  63.         set returnThis to areYouThere(i, xLoc)
  64.         if returnThis then
  65.           set activeObject to i
  66.           set newrollover to 1
  67.           set thisRollOver to 1
  68.           sendmouseevents(me, xLoc)
  69.           exit repeat
  70.         end if
  71.       end repeat
  72.     else
  73.       set returnThis to 0
  74.     end if
  75.   else
  76.     set nextrollover to areYouThere(activeObject, thisMouseLoc)
  77.     set newrollover to nextrollover <> thisRollOver
  78.     set thisRollOver to nextrollover
  79.     set returnThis to sendmouseevents(me, thisMouseLoc)
  80.   end if
  81.   return returnThis
  82. end
  83.  
  84. on pointCursor me
  85.   global savedcursor
  86.   sendoff("cursor: [point]")
  87.   set savedcursor to #point
  88. end
  89.  
  90. on grabCursor me
  91.   global savedcursor
  92.   sendoff("cursor: [grab]")
  93.   set savedcursor to #grab
  94. end
  95.  
  96. on plainCursor me
  97.   global savedcursor
  98.   sendoff("cursor: [plain]")
  99.   set savedcursor to #plain
  100. end
  101.  
  102. on blankCursor me
  103.   global savedcursor
  104.   sendoff("cursor: [blank]")
  105.   set savedcursor to #blank
  106. end
  107.  
  108. on sendmouseevents me, xPoint
  109.   set sendmousedown to 0
  110.   set sendmouseup to 0
  111.   set sendmouseenter to 0
  112.   set sendmouseleave to 0
  113.   set sendmousemove to 0
  114.   set sendmousedrag to 0
  115.   set sendmousegone to 0
  116.   if newrollover then
  117.     if thisRollOver then
  118.       set sendmouseenter to 1
  119.     else
  120.       set sendmouseleave to 1
  121.       if not thisStillDown then
  122.         set sendmousegone to 1
  123.       end if
  124.     end if
  125.   end if
  126.   if newstilldown then
  127.     if thisRollOver then
  128.       if thisStillDown then
  129.         set sendmousedown to 1
  130.       else
  131.         set sendmouseup to 1
  132.       end if
  133.     else
  134.       set sendmousegone to 1
  135.     end if
  136.   end if
  137.   if newmouseloc then
  138.     if thisStillDown then
  139.       set sendmousedrag to 1
  140.     else
  141.       if thisRollOver then
  142.         set sendmousemove to 1
  143.       end if
  144.     end if
  145.   end if
  146.   set thistime to the ticks
  147.   if sendmousegone then
  148.     set sendmousedrag to 0
  149.     set sendmousemove to 0
  150.   end if
  151.   if sendmouseenter then
  152.     set sendmouseup to 0
  153.     mouseEvent(activeObject, #mouseEnter, thisMouseLoc)
  154.   end if
  155.   if sendmousedown then
  156.     mouseEvent(activeObject, #mouseDown, thisMouseLoc)
  157.   end if
  158.   if sendmousedrag then
  159.     mouseEvent(activeObject, #mouseDrag, thisMouseLoc)
  160.   end if
  161.   if sendmouseup then
  162.     mouseEvent(activeObject, #mouseUp, thisMouseLoc)
  163.   end if
  164.   if sendmousemove then
  165.     mouseEvent(activeObject, #mouseMove, thisMouseLoc)
  166.   end if
  167.   if sendmouseleave then
  168.     mouseEvent(activeObject, #mouseLeave, thisMouseLoc)
  169.   end if
  170.   if sendmousegone then
  171.     mouseEvent(activeObject, #mouseGone, thisMouseLoc)
  172.     set activeObject to 0
  173.   end if
  174.   return thisRollOver
  175. end
  176.  
  177. on resetcursor me
  178.   global savedcursor
  179.   case savedcursor of
  180.     #point:
  181.       pointCursor(me)
  182.     #grab:
  183.       grabCursor(me)
  184.     #plain:
  185.       plainCursor(me)
  186.     #blank:
  187.       blankCursor(me)
  188.   end case
  189. end
  190.